package com.cskaoyan.wordmemorize.controller.app;

import com.cskaoyan.wordmemorize.auth.StpKit;
import com.cskaoyan.wordmemorize.common.result.Result;
import com.cskaoyan.wordmemorize.dto.app.UserRemindDTO;
import com.cskaoyan.wordmemorize.request.UserRemindCommand;
import com.cskaoyan.wordmemorize.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/remind")
public class SmsReminderController {

    @Autowired
    UserService userService;

    // 更新App端用户的学习提醒时间
    @PutMapping("")
    public Result updateUserRemind(@RequestBody UserRemindCommand command) {

        Long userId = StpKit.USER.getLoginIdAsLong();
        userService.updateUserRemind(command,userId);
        UserRemindDTO userRemind = userService.getUserRemind(userId);

        return Result.ok(userRemind);
    }

}
